﻿using DXApplicationTangche.Utils;
using mendian;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace DXApplicationTangche.service
{
    /// <summary>
    /// 资源服务
    /// </summary>
    class ResourceService
    {
        /// <summary>
        /// 同步图片资源到本地
        /// </summary>
        public static void synPictureResouces()
        {
            if (!Directory.Exists(@"xml"))
            {
                Directory.CreateDirectory(@"xml");
            }
            if (!Directory.Exists(@"pic"))
            {
                Directory.CreateDirectory(@"pic");
            }
            if (!Directory.Exists(@"doc"))
            {
                Directory.CreateDirectory(@"doc");
            }
            if (!Directory.Exists(@"tag"))
            {
                Directory.CreateDirectory(@"tag");
            }
            if (!Directory.Exists(@"pic"))
            {
                Directory.CreateDirectory(@"pic");
            }
            if (!Directory.Exists(@"pdf"))
            {
                Directory.CreateDirectory(@"pdf");
            }
            /*
            //款式图片更新
            StylePicList spl = new StylePicList();
            List<StylePic> styleOldlist = DealXML.XMLFlieToObject<List<StylePic>>(@"xml\stylepicxml.xml", Encoding.UTF8);
            List<StylePic> styleDifflist = ResourceService.listCompare(spl.stylepiclist, styleOldlist);
            PictureService.DownloadDifferentPic(styleDifflist);
            bool yn = DealXML.ObjectToXMLFile(spl.stylepiclist, @"xml\stylepicxml.xml", Encoding.UTF8);
            //面料图片更新
            MianLiaoPicList mlpl = new MianLiaoPicList();
            //bool mlyn = DealXML.ObjectToXMLFile(mlpl.mianliaopiclist, @"mlpicxml.xml", Encoding.UTF8);
            List<MianLiaoPic> mianliaoOldlist = DealXML.XMLFlieToObject<List<MianLiaoPic>>(@"xml\mlpicxml.xml", Encoding.UTF8);
            List<MianLiaoPic> mianliaoDifflist = ResourceService.mianliaolistCompare(mlpl.mianliaopiclist, mianliaoOldlist);
            PictureService.DownloadMianliaoPic(mianliaoDifflist);
            bool mlyn = DealXML.ObjectToXMLFile(mlpl.mianliaopiclist, @"xml\mlpicxml.xml", Encoding.UTF8);
            //设计点图片更新
            SheJiDianPicList sjdpl = new SheJiDianPicList();
            //bool shjdyn = DealXML.ObjectToXMLFile(sjdpl.shejidianpiclist, @"xml\shjdpicxml.xml", Encoding.UTF8);
            List<SheJiDianPic> shejidianOldlist = DealXML.XMLFlieToObject<List<SheJiDianPic>>(@"xml\shjdpicxml.xml", Encoding.UTF8);
            List<SheJiDianPic> shejidianDifflist = ResourceService.shejidianlistCompare(sjdpl.shejidianpiclist, shejidianOldlist);
            PictureService.DownloadSheJiDianPic(shejidianDifflist);
            bool shjdyn = DealXML.ObjectToXMLFile(sjdpl.shejidianpiclist, @"xml\shjdpicxml.xml", Encoding.UTF8);
            */
        }
    }
}
